<?php

function hasChildGallery($idp)
{
	global $dbsql;
	$idp=intval($idp);
	//-----------------------------------------------------
	$sql_select = "select iId from tblgallery where  iParentId = $idp";

	$rs=$dbsql->query($sql_select);
	$rows = $dbsql->num_rows($rs);
	if($rows>0)return true;
	return false;
}

function ListContentGallery($id)
{
	global $language,$dbsql;
    $contents   = array();

    $sql_where  = "from tblgallery where iParentId = '$id' and cType = '' ";

	$sql_select="SELECT count(iId) as count ".$sql_where;
	$result=$dbsql->query_fetch($sql_select);
	$count_all=$result['count'];
	if($count_all==0)return  $contents;

	list($lmstart,$lmlength)=Slit_Page($count_all);

	$sql_select = "SELECT * ".$sql_where." order by iOrder Asc limit $lmstart,$lmlength";

	$rs=$dbsql->query($sql_select);
	while ( $result = $dbsql->fetch_array($rs) )
	{
		$file=basename($result['cImage']);
		$result['cThumb']=str_replace($file,"thumbs/".$file,$result["cImage"]);
		$contents[] = $result;
	}
    return $contents;
}
?>